﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Shapes;

namespace SharpSoft.WPF.App
{
    /// <summary>
    /// ErrorDialog.xaml 的交互逻辑
    /// </summary>
    public partial class ErrorDialog : Window
    {
        public ErrorDialog()
        {
            InitializeComponent();
        }

        public string Message
        {
            get { return (string)GetValue(MessageProperty); }
            set { SetValue(MessageProperty, value); }
        }

        public static readonly DependencyProperty MessageProperty =
            DependencyProperty.Register("Message", typeof(string), typeof(ErrorDialog), new PropertyMetadata(""));

        private void btn_close_Click(object sender, RoutedEventArgs e)
        {
            this.Close();
        }

        public void ShowError(Exception ex)
        {
            if (ex != null)
            {
                this.Message += ex.Message + "\n";
                this.Message += ex.StackTrace;
            }
            else
            {
                this.Message = "未知异常，无错误详情。";
            }

            this.Show();


        }
    }
}
